home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / srcuc.zip / PRDOSENV.C < prev    next >
C/C++ Source or Header  |  1992-05-25  |  5KB  |  163 lines

  1. /* -*-C-*-
  2.  
  3. $Header: /scheme/src/microcode/RCS/prdosenv.c,v 1.3 1992/05/25 16:20:10 jinx Exp $
  4.  
  5. Copyright (c) 1992 Massachusetts Institute of Technology
  6.  
  7. This material was developed by the Scheme project at the Massachusetts
  8. Institute of Technology, Department of Electrical Engineering and
  9. Computer Science.  Permission to copy this software, to redistribute
  10. it, and to use it for any purpose is granted, subject to the following
  11. restrictions and understandings.
  12.  
  13. 1. Any copy made of this software must include this copyright notice
  14. in full.
  15.  
  16. 2. Users of this software agree to make their best efforts (a) to
  17. return to the MIT Scheme project any improvements or extensions that
  18. they make, so that these may be included in future releases; and (b)
  19. to inform MIT of noteworthy uses of this software.
  20.  
  21. 3. All materials developed as a consequence of the use of this
  22. software shall duly acknowledge such use, in accordance with the usual
  23. standards of acknowledging credit in academic research.
  24.  
  25. 4. MIT has made no warrantee or representation that the operation of
  26. this software will be error-free, and MIT is under no obligation to
  27. provide any services, by way of maintenance, update, or otherwise.
  28.  
  29. 5. In conjunction with products arising from the use of this material,
  30. there shall be no use of the name of the Massachusetts Institute of
  31. Technology nor of any adaptation thereof in any advertising,
  32. promotional, or sales literature without prior written consent from
  33. MIT in each case. */
  34.  
  35. /* Unix-specific process-environment primitives. */
  36. /* DOS imitation */
  37.  
  38. #include "scheme.h"
  39. #include "prims.h"
  40. #include "msdos.h"
  41.  
  42. DEFINE_PRIMITIVE ("CURRENT-FILE-TIME", Prim_current_file_time, 0, 0,
  43.   "Return the current file system time stamp.\n\
  44. This is an integer whose units are in seconds.")
  45. {
  46.   PRIMITIVE_HEADER (0);
  47.   PRIMITIVE_RETURN (long_to_integer (DOS_time (NULL)));
  48. }
  49.  
  50. DEFINE_PRIMITIVE ("FILE-TIME->STRING", Prim_file_time_to_string, 1, 1,
  51.   "Convert a file system time stamp into a date/time string.")
  52. {
  53.   PRIMITIVE_HEADER (1);
  54.   CHECK_ARG (1, INTEGER_P);
  55.   {
  56.     time_t clock = (arg_integer (1));
  57.     char * time_string = (DOS_ctime (&clock));
  58.     (time_string[24]) = '\0';
  59.     PRIMITIVE_RETURN (char_pointer_to_string ((unsigned char *) time_string));
  60.   }
  61. }
  62.  
  63. DEFINE_PRIMITIVE ("GET-USER-HOME-DIRECTORY", Prim_get_user_home_directory, 1, 1,
  64.   "Return the file name of a given user's home directory.\n\
  65. The user name argument must be a string.\n\
  66. If no such user is known, #F is returned.")
  67. {
  68.   PRIMITIVE_HEADER (1);
  69.   PRIMITIVE_RETURN (char_pointer_to_string ((unsigned char *) "c:\\"));
  70. }
  71.  
  72. DEFINE_PRIMITIVE ("UID->STRING", Prim_uid_to_string, 1, 1,
  73.   "Return the user name corresponding to UID.\n\
  74. If the argument is not a known user ID, #F is returned.")
  75. {
  76.   PRIMITIVE_HEADER (1);
  77.   PRIMITIVE_RETURN (SHARP_F);
  78. }
  79.  
  80. DEFINE_PRIMITIVE ("GID->STRING", Prim_gid_to_string, 1, 1,
  81.   "Return the group name corresponding to GID.\n\
  82. If the argument is not a known group ID, #F is returned.")
  83. {
  84.   PRIMITIVE_HEADER (1);
  85.   PRIMITIVE_RETURN (SHARP_F);
  86. }
  87.  
  88. DEFINE_PRIMITIVE ("CURRENT-UID", Prim_current_uid, 0, 0,
  89.   "Return Scheme's effective UID.")
  90. {
  91.   PRIMITIVE_HEADER (0);
  92.   PRIMITIVE_RETURN (long_to_integer (0));
  93. }
  94.  
  95. DEFINE_PRIMITIVE ("CURRENT-GID", Prim_current_gid, 0, 0,
  96.   "Return Scheme's effective GID.")
  97. {
  98.   PRIMITIVE_HEADER (0);
  99.   PRIMITIVE_RETURN (long_to_integer (0));
  100. }
  101.  
  102. DEFINE_PRIMITIVE ("SYSTEM", Prim_system, 1, 1,
  103.   "Invoke sh (the Bourne shell) on the string argument.\n\
  104. Wait until the shell terminates, returning its exit status as an integer.")
  105. {
  106.   PRIMITIVE_HEADER (1);
  107.   PRIMITIVE_RETURN (long_to_integer (-1));
  108. }
  109.  
  110. DEFINE_PRIMITIVE ("UNIX-ENVIRONMENT", Prim_unix_environment_alist, 0, 0,
  111.   "Copy the unix environment and return it as a vector of strings.")
  112. {
  113.   PRIMITIVE_HEADER (0);
  114.   PRIMITIVE_RETURN (SHARP_F);
  115. }
  116.  
  117. DEFINE_PRIMITIVE ("FULL-HOSTNAME", Prim_full_hostname, 0, 0,
  118.   "Returns the full hostname (including domain if available) as a string.")
  119. {
  120.   PRIMITIVE_HEADER (0);
  121.   PRIMITIVE_RETURN
  122.     (char_pointer_to_string ((unsigned char *) "PC"));
  123. }
  124.  
  125. DEFINE_PRIMITIVE ("HOSTNAME", Prim_hostname, 0, 0,
  126.   "Returns the hostname of the machine as a string.")
  127. {
  128.   PRIMITIVE_HEADER (0);
  129.   PRIMITIVE_RETURN
  130.     (char_pointer_to_string ((unsigned char *) "IBMPC"));
  131. }
  132.  
  133. DEFINE_PRIMITIVE ("DOS-SET-KEYBOARD-MODIFIER-MASK!", Prim_dos_set_kbd_mod_mask,
  134.           1, 1,
  135.           "Set the keyboard modifier mask")
  136. {
  137.   extern unsigned char EXFUN (dos_set_kbd_modifier_mask, (unsigned char));
  138.   PRIMITIVE_HEADER (1);
  139.   
  140.   PRIMITIVE_RETURN (long_to_integer
  141.             ((long)
  142.              (dos_set_kbd_modifier_mask ((unsigned char)
  143.                          (arg_integer (1))))));
  144. }
  145.  
  146. DEFINE_PRIMITIVE ("DOS-SET-KEYBOARD-TRANSLATION!",
  147.           Prim_dos_set_keyboard_translation,
  148.           3, 3, 0)
  149. {
  150.   int result;
  151.   extern int EXFUN (dos_set_kbd_translation,
  152.             (unsigned, unsigned, unsigned char));
  153.   PRIMITIVE_HEADER (3);
  154.   
  155.   result = (dos_set_kbd_translation (((unsigned) (arg_integer (1))),
  156.                      ((unsigned) (arg_integer (2))),
  157.                      ((unsigned char) (arg_integer (3)))));
  158.   if (result < 0)
  159.     error_bad_range_arg (2);
  160.  
  161.   PRIMITIVE_RETURN (long_to_integer ((long) result));
  162. }
  163.